package gggameserver.games;

public class Position {

	private int x;
	private int y;

	public Position(int x, int y) {
		this.x = x;
		this.y = y;
	}

	public Position(final Position p) {
		this.x = p.x;
		this.y = p.y;
	}

	public Position add(final Position p) {
		this.x += p.x;
		this.y += p.y;
		return this;
	}

	public int getX() {
		return x;
	}

	public void setX(int x) {
		this.x = x;
	}

	public int getY() {
		return y;
	}

	public void setY(int y) {
		this.y = y;
	}

	public void set(final Position p) {
		this.x = p.x;
		this.y = p.y;
	}

	@Override
	public String toString() {
		return "[x=" + x + ", y=" + y + "]";
	}

	@Override
	public int hashCode() {
		return x * 17 + y * 11;
	}

	@Override
	public boolean equals(Object obj) {
		boolean result = false;
		if (obj != null && obj instanceof Position) {
			Position p = (Position) obj;
			if (this.x == p.getX() && this.y == p.getY()) {
				result = true;
			}
		}
		return result;
	}

}